package com.lzb.play.utils;

import com.blankj.utilcode.util.GsonUtils;
import com.blankj.utilcode.util.SPUtils;
import com.google.gson.reflect.TypeToken;
import com.lzb.play.bean.GridBean;
import com.lzb.play.bean.PianoKeyBean;

import java.util.List;


public class AppSpUtils {
    private static final String SP_NAME = "appCollSp";
    private static final SPUtils sSpUtils = SPUtils.getInstance(SP_NAME);

    public static void savePianoKeyList(List<PianoKeyBean> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_piano_key_list, json);
    }

    public static List<PianoKeyBean> getPianoKeyList() {
        String json = sSpUtils.getString(Key.key_piano_key_list);
        return GsonUtils.fromJson(json, new TypeToken<List<PianoKeyBean>>() {
        }.getType());
    }

    public static void saveGridList(List<GridBean> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_grid_list, json);
    }

    public static List<GridBean> getGridList() {
        String json = sSpUtils.getString(Key.key_grid_list);
        return GsonUtils.fromJson(json, new TypeToken<List<GridBean>>() {
        }.getType());
    }

    interface Key {
        String key_piano_key_list = "key_piano_key_list";
        String key_grid_list = "key_grid_list";
    }
}